package behaviour.chain.chain_demo1;

/**
 * @author yeyangtao
 * @date 2020/6/24 14:46
 */
public abstract class AbstractLogger {
    public static final int INFO = 1;
    public static final int DEBUG = 2;
    public static final int ERROR = 3;
    protected int level;

    //下一个链
    protected AbstractLogger next;

    public void setNext(AbstractLogger next) {
        this.next = next;
    }

    public void loadMessage(int level, String message) {
        if (this.level <= level) {
            write(message);
        }
        if (next != null) {
            next.loadMessage(level, message);
        }
    }

    protected abstract void write(String message);
}
